<template>
  <div class="boxran">
    <!-- 头部 -->
    <div class="htear">
      <div class="left">
        <div
          @click="$router.go(-1)"
          class="return iconfont icon-arrowRight-copy-copy"
        ></div>
        <div class="name">排行榜</div>
      </div>
      <div class="age">
        <router-link tag="div" to="/schoolboy" class="com">男生</router-link>
        <router-link tag="div" to="/girlstudent">女生</router-link>
      </div>
      <div class="right">
        <router-link tag="div" to="/search" class="searchcon iconfont icon-31sousuo"></router-link>
        <div
          is-link
          @click="showPopup"
          class="classification iconfont icon-a-gengduofenlei"
        ></div>
      </div>
    </div>
    <!-- 弹出内容 -->
    <van-popup
      closeable
      v-model="show"
      position="top"
      :style="{ height: '45%' }"
    >
      <div class="boxpopup">
        <!-- 头部 -->
        <div class="htears">
          <div class="left">
            <div
              @click="$router.go(-1)"
              class="return iconfont icon-arrowRight-copy-copy"
            ></div>
            <div class="name">排行榜</div>
          </div>
        </div>
        <!-- 分类 -->
        <div class="guide-nav">
          <router-link tag="div" to="/schoolboy" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-home-copy"></use>
            </svg>
            <div class="boxtext">首页</div>
          </router-link>
          <router-link tag="div" to="/classification" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-fenlei"></use>
            </svg>
            <div>分类</div>
          </router-link>
          <router-link tag="div" to="/rankinglist" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-daochu1024-02"></use>
            </svg>
            <div>排行榜</div>
          </router-link>
          <router-link tag="div" to="/cover" class="box">
            <svg class="icon" aria-hidden="true">
              <use
                xlink:href="#icon-a-travelhotelholidayvacationcdlistingboo"
              ></use>
            </svg>
            <div>免费</div>
          </router-link>
          <router-link tag="div" to="/end" class="box">
            <svg class="icon sw" aria-hidden="true">
              <use xlink:href="#icon-wanjietuijian"></use>
            </svg>
            <div>完本</div>
          </router-link>
          <router-link tag="div" to="/okami" class="box">
            <svg class="icon" aria-hidden="true">
              <use xlink:href="#icon-huangguan"></use>
            </svg>
            <div>大神</div>
          </router-link>
        </div>
        <!-- 我的书架 -->
        <router-link tag="div" to="/bookshelf" class="mybookshelf">我的书架</router-link>
      </div>
    </van-popup>
    <!-- 排行 -->
    <!-- 月票榜 -->
    <div v-for="(item,index) in rankinglists" :key="index" class="rankinglists">
      <!-- <div class="top">
        <div>月票榜</div>
        <span class="iconfont icon-arrowRight-copy-copy-copy"></span>
      </div> -->
      <div class="center">
        <router-link tag="div" :to="'/more?name=' + item.name" class="left">
          <img
            :src="item.image"
            alt=""
          />
          <div class="text">{{item.name}}</div>
          <div class="arrow iconfont icon-jiantou_xiangyou"></div>
        </router-link>
        <div class="right">
          <ul>
            <li @click="bookdeta(v.id)" v-for="(v,i) in item.rankinglis" :key="i">
              <span>{{i+1}}.{{v.text}}</span
              ><span class="iconfont icon-arrowRight-copy-copy-copy"></span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    
  </div>
</template>

<script>
export default {
  data() {
    return {
      show: false, //弹出判断
      //排行榜数据
      rankinglists:[{
        name:"月票榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-1.c077f.jpg"
      },{
        name:"畅销榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-2.868f8.jpg"
      },{
        name:"阅读榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-11.d5b17.jpg"
      },{
        name:"粉丝榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-3.cd1bc.jpg"
      },{
        name:"推荐榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-4.b5dae.jpg"
      },{
        name:"打赏榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-5.5e078.jpg"
      },{
        name:"更新榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-6.e2ab8.jpg"
      },{
        name:"签约榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-10.bdd56.jpg"
      },{
        name:"新书榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-11.d5b17.jpg"
      },{
        name:"新人榜",
        image:"https://qidian.gtimg.com/qdm/img/rank/rank-bg-12.c7185.jpg"
      }],
    };
  },
  methods: {
    //头部弹出
    showPopup() {
      this.show = true;
    },
    // 路由跳转传参
    bookdeta(id) {
      this.$router.push({
        path: "/bookdetails",
        query: {
          id: id
        },
      });
    },
  },
  created(){
    this.$axios.get("/static.json").then((res) => {
      let data = res.data;
      this.rankinglists = data.rankinglists;//排行榜数据
      console.log(this.rankinglists)
    })
  }
};
</script>

<style lang="less">
.boxran {
  // 关闭按钮
  .van-popup__close-icon--top-right {
    top: 13px;
  }
  .boxpopup {
    .htears {
      width: 100%;
      display: flex;
      height: 22px;
      padding: 11px 0px 10px 0px;
      justify-content: space-between;
      align-items: center;
      .age {
        display: flex;
        height: 24px;
        border: 1px solid #ed424b;
        border-radius: 3px;
        div {
          font-size: 15px;
          line-height: 24px;
          color: #ed424b;
          padding: 0px 10px;
        }
        .com {
          background: #ed424b;
          color: white;
        }
      }
      .left,
      .right {
        display: flex;
        div {
          padding: 0px 10px;
          text-align: center;
          font-size: 18px;
          color: #3c3b3b;
        }
        .name {
          font-size: 14px;
          color: #424141;
        }
        .return {
          color: black;
        }
      }
    }
    .guide-nav {
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
      padding: 0px 16px;
      .box {
        width: 58px;
        height: 58px;
        line-height: 58px;
        text-align: center;
        margin: 12px 24px;
        div {
          position: relative;
          top: -33px;
          font-size: 14px;
        }
      }
    }
    .mybookshelf {
      margin: 20px 50px;
      text-align: center;
      padding: 8px 0px;
      font-size: 14px;
      color: white;
      font-weight: 500;
      background-color: #ed424b;
      border-radius: 20px;
    }
    .sw {
      font-size: 40px;
    }
  }
  .htear {
    width: 100%;
    display: flex;
    height: 22px;
    padding: 11px 0px 10px 0px;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e8e7e7;
    background-color: white;
    .left,
    .right {
      display: flex;
      div {
        padding: 0px 10px;
        text-align: center;
        font-size: 18px;
        color: #3c3b3b;
      }
      .name {
        font-size: 14px;
        color: #424141;
      }
      .return {
        color: black;
      }
    }
    .age {
      display: flex;
      height: 24px;
      border: 1px solid #ed424b;
      border-radius: 3px;
      div {
        font-size: 15px;
        line-height: 24px;
        color: #ed424b;
        padding: 0px 10px;
      }
      .com {
        background: #ed424b;
        color: white;
      }
    }
  }
  .rankinglists {
    width: 100%;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    background-color: white;
    .top {
      display: flex;
      width: calc(100% - 12px);
      justify-content: space-between;
      padding: 10px 0px;
      margin-left: 12px;
      border-bottom: 1px solid #eae6e6;
      div {
        color: black;
        font-size: 16px;
        font-weight: 600;
      }
      span {
        margin-right: 9px;
      }
    }
    .center {
      display: flex;
      .left {
        width: 120px;
        height: 178px;
        margin-right: 15px;
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        img {
          width: 100%;
          height: 100%;
        }
        .text {
          position: absolute;
          color: white;
          top: 50px;
          font-size: 28px;
          font-weight: 900;
        }
        .arrow {
          width: 25px;
          top: 120px;
          height: 25px;
          border-radius: 50%;
          background-color: white;
          position: absolute;
          text-align: center;
          line-height: 25px;
          color: #969696;
        }
      }
      .right {
        ul {
          li {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 14px;
            color: #33373d;
            padding: 8px 0px;
            font-weight: 600;
            width: 230px;
            border-bottom: 1px solid #efeeee;
            .icon-arrowRight-copy-copy-copy {
              color: #bbb;
              font-size: 14px;
            }
          }
        }
      }
    }
  }
}
</style>